<?php

namespace Modules\Ui\component;


use Duxravel\Core\UI\Widget;
use Duxravel\Core\UI\Widget\Icon;
use Modules\Ui\Traits\Makenable;

class Modal extends Component
{
    use Makenable;

    protected string $nodeName = 'a-modal';


    public function __construct($title)
    {
        $this->attr("title",$title);
        $this->vModel('visible');
//        $this->data(['visible'=>'this.visible']);
//        $this->vOn('ok','toggleVisible')
//            ->vOn('cancel','toggleVisible');
//        $this->attr('closable',false)
//            ->attr('fullscreen',false);
        $action = Element::make(function (Element $element){
            $element->nodeName('span');
            $element->addClass('cursor-pointer');
            $element->vSlot('action');
            $element->click('onClickFull');//处理
            $element->addChild([
                'nodeName'=>'icon-fullscreen-exit',
                'vIf'=>'isFullscreen'
            ])->addChild([
                'nodeName'=>'icon-fullscreen',
                'vIf'=>'!isFullscreen'
            ]);
        });
        $header = Element::make(function (Element $element) use ($title,$action) {
            $element->nodeName('a-alert');
            $element->vSlot('title');
            $element->attr('show-icon',false);
            $element->attr('closable',true);
            $element->addChild(['nodeName'=>'span','vSlot:title'=>'','child'=>$title])->addChild($action);
        });

//        $this->addChild($header);
            $this->addChild([
            'nodeName'=>'div',
            'child'=>"测试"
        ]);
    }


//    public function jsonSerialize()
//    {
//        return parent::jsonSerialize();
//    }

}
